package com.dylan.equipment.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dylan.equipment.dao.IEquipmentDao;
import com.dylan.equipment.entity.Equipment;
import com.dylan.equipment.entity.PageBean;
import com.dylan.equipment.utils.StringUtil;
@Service
public class EquipmentService {
	
	@Resource
	private IEquipmentDao equipmentDao;
	public List<Equipment> find (PageBean page,Equipment s_equipment){
		Map<String, Object> params = new HashMap<>();
		if(page!=null){
			params.put("start", page.getStart());
			params.put("pageSize", page.getPageSize());
		}
		if(StringUtil.isNotEmpty(s_equipment.getTypeName())){
			params.put("typeName", s_equipment.getTypeName());
		}
		return equipmentDao.find(params);
	}
	public int count(Equipment s_equipment){
		return equipmentDao.count(s_equipment);
	}
	public void add(Equipment equipment){
		equipmentDao.add(equipment);
	}
	public void update(Equipment equipment){
		equipmentDao.update(equipment);
	}
	public void delete(int id){
		equipmentDao.delete(id);
	}
	public Equipment loadById(int id){
		return equipmentDao.loadById(id);
	}
	public boolean existEquipmentByTypeId(int typeId){
		List<Equipment> list = equipmentDao.existEquipmentByTypeId(typeId);
		if(list.isEmpty()){
			return false;
		}else{
			return true;
		}
			
	}
}
